import React, { useState } from 'react';
import useMyReducer from '../../reducer';
import {useNavigate} from 'react-router-dom'
const Index = () => {
    const navigate =useNavigate();
    const [state,dispatch] =useMyReducer()
    const [citys] =useState(["杭州","厦门","成都","武汉"])
    const handleCity =(val)=>{
        dispatch({
            type:"changeCity",
            value:val
        })
        navigate(-1)
    }
    return (
        <div>
            {citys.map(item=>{
                return (<button onClick={()=>handleCity(item)} key={item}>{item}</button>)
            })}
            
        </div>
    );
}

export default Index;
